CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(dbeng)

include_directories(${dbeng_BINARY_DIR})

# DEBUG
#add_definitions(-g -DNDEBUGPRINT -DNDEBUG -O6 -Wall -Wextra)
add_definitions(-g -Wall -Wextra -DNDEBUGPRINT)
#set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})

add_library(fdb SHARED
	common/arity.c
	common/avltree.c
	common/cache.c
	common/io.c
	common/charreader.c
	common/datatype.c
	common/filelock.c
	common/linkedlist.c
	common/util.c

	database/database.c

	datatypes/manifest.c
	datatypes/string.c
	datatypes/int64.c
	datatypes/array.c
	datatypes/float64.c

	transaction/abortlog.c
	transaction/transaction.c
	transaction/transactionlist.c
	transaction/transactionlog.c

	storage/storage.c
	storage/fsm.c
	storage/page.c
	storage/blob/page_blob.c
	storage/tuple/tuple.c
	storage/tuple/page_tuple.c

	maintenance/vacuum.c

	table/table.c
	table/column.c

	query/blobify.c
	query/condition.c
	query/filter.c
	query/query.c
	query/result.c
	query/iterator.c
	query/iterators/ftscan.c
	query/commands/select.c
	query/commands/delete.c
	query/commands/insert.c
	query/commands/update.c
)

add_library(fdb-helpers SHARED
	helpers/array.c
	helpers/sequence.c
	helpers/manifest.c
)

add_library(fdbstat STATIC
	common/arity.c
	common/avltree.c
	common/cache.c
	common/io.c
	common/charreader.c
	common/datatype.c
	common/filelock.c
	common/linkedlist.c
	common/util.c

	database/database.c

	datatypes/manifest.c
	datatypes/string.c
	datatypes/int64.c
	datatypes/array.c
	datatypes/float64.c

	transaction/abortlog.c
	transaction/transaction.c
	transaction/transactionlist.c
	transaction/transactionlog.c

	storage/storage.c
	storage/fsm.c
	storage/page.c
	storage/blob/page_blob.c
	storage/tuple/tuple.c
	storage/tuple/page_tuple.c

	maintenance/vacuum.c

	table/table.c
	table/column.c

	query/blobify.c
	query/condition.c
	query/filter.c
	query/query.c
	query/result.c
	query/iterator.c
	query/iterators/ftscan.c
	query/commands/select.c
	query/commands/delete.c
	query/commands/insert.c
	query/commands/update.c
)

# Debugging build?
#OPTION(DEBUG "Debug build" OFF)
#IF (DEBUG)
#	ADD_DEFINITIONS(-g)
#ELSE(DEBUG)
#	ADD_DEFINITIONS(-DNDEBUG -DNDEBUGPRINT -O6)
#ENDIF(DEBUG)

#add_library(fdb SHARED libfdb.c
#)
#
add_executable(bin/tableinspect bin/tableinspect.c)
target_link_libraries(bin/tableinspect fdb)

add_executable(bin/txlog bin/txlog.c)
target_link_libraries(bin/txlog	fdbstat)

add_executable(bin/vacuum bin/vacuum.c)
target_link_libraries(bin/vacuum fdb)

add_executable(bin/pageinfo bin/pageinfo.c)
target_link_libraries(bin/pageinfo fdbstat )
#
#add_executable(tests/units/test1 tests/units/test1.c)
#target_link_libraries(tests/units/test1 fdb)
#
#add_executable(tests/units/test2-select tests/units/test2-select.c)
#target_link_libraries(tests/units/test2-select fdb)

add_executable(tests/benchmarks/setup/base tests/benchmarks/setup/base.c)
target_link_libraries(tests/benchmarks/setup/base fdb fdb-helpers)
add_executable(tests/benchmarks/benchmark10/base tests/benchmarks/benchmark10/base.c)
target_link_libraries(tests/benchmarks/benchmark10/base fdb fdb-helpers)
add_executable(tests/benchmarks/benchmark11/base tests/benchmarks/benchmark11/base.c)
target_link_libraries(tests/benchmarks/benchmark11/base fdb fdb-helpers)
add_executable(tests/benchmarks/benchmark12/base tests/benchmarks/benchmark12/base.c)
target_link_libraries(tests/benchmarks/benchmark12/base fdb fdb-helpers)
add_executable(tests/benchmarks/benchmark13/base tests/benchmarks/benchmark13/base.c)
target_link_libraries(tests/benchmarks/benchmark13/base fdb fdb-helpers)

add_executable(tests/benchmarks/benchmark20/base tests/benchmarks/benchmark20/base.c)
target_link_libraries(tests/benchmarks/benchmark20/base fdb fdb-helpers)

add_executable(tests/benchmarks/benchmark30/base tests/benchmarks/benchmark30/base.c)
target_link_libraries(tests/benchmarks/benchmark30/base fdb fdb-helpers)
